home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TC2PROM.ARJ / ROMEXMPL.C < prev    next >
Text File  |  1991-05-01  |  982b  |  51 lines

  1. /* ROMEXMPL.C   - Example ROMable Turbo C program */
  2.  
  3. #include <dos.h>
  4.  
  5.  
  6. #define  portin         0x300
  7. #define  portout        0x301
  8.  
  9. /* Here are examples of how to re-create some of
  10.     the library string functions */
  11.  
  12. void strmv(char *dest, char *source) { /* like copy, but does not move
  13.                                          terminating null */
  14.   while (*source) *dest++ = *source++;
  15. }
  16.  
  17. int strlen(char *source) {
  18.   int i;
  19.   i = 0;
  20.   while (*source++) i++;
  21.   return (i);
  22. }
  23.  
  24. void strcpy(char *dest, char *source) {
  25.   while (*source) *dest++ = *source++;
  26.   *dest = *source;  /* move terminator */
  27. }
  28.  
  29. void send_mess(char *p) {
  30.  
  31.   while (*p) outportb(portout,*p++);
  32. }
  33.  
  34. void do_stuff() {
  35.  
  36.   static char *menu[] = { "Choice A", "Choice B", "Choice C"};
  37.   int i;
  38.  
  39.   i = inportb(portin);
  40.   send_mess(menu[i]);
  41. }
  42.  
  43. void main(void) {
  44.   do {
  45.     do_stuff();
  46.   } while (1);
  47.  
  48.   /* don't return from main, there ain't no place to go */
  49.  
  50. }
  51.